<template>
	<view>
		<view class="login-from">
			<view class="login-username-password-container">
				<text>账号密码设置</text>
			</view>
			<view class="input-container">
				<text class="input-label">账号：</text>
				<input type="text" value="" class="blog-input" v-model="userInfo.username" placeholder="请输入账号" />
			</view>
			<view class="input-container">
				<text class="input-label">密码：</text>
				<input type="password" value="" class="blog-input" v-model="userInfo.password" placeholder="请输入密码" />
			</view>
			<view class="submit-button-container">
				<button type="primary" class="submit-button" @click="submitForm">提交</button>
			</view>
		</view>
		
	</view>
</template>

<script>
import userApi from '@/api/myUser.js'
import md5 from 'js-md5'
export default {
	data() {
		return {
			userInfo: {
				username: '',
				password: ''
			}
		};
	},
	methods: {
		submitForm() {
			this.userInfo.password = md5(this.userInfo.password)
			userApi.updateUsername(this.userInfo).then(res => {
				uni.showToast({
					title: res.msg,
					icon: 'success'
				})
				// 跳转到我的
				uni.reLaunch({
					url: '/pages/mine/mine'
				})
			})
		}
	}
};
</script>

<style>
@import url('./index.css');
</style>
